package nc;
import java.util.*;


import org.junit.*;

public class Vivo2 {
    static class Main1 {
        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            String s = sc.nextLine();
            char[] cs = s.toCharArray();
            sc.close();

            int n = cs.length;

            for (int i = 0; i < n; i++) {
                if (deleteCanBe(cs, i)) {
                    StringBuilder sb = new StringBuilder();
                    for (int j = 0; j < n; j++) {
                        if (j != i) {
                            sb.append(cs[j]);
                        }
                    }
                    System.out.println(sb.toString());
                    return;
                }
            }
        }

        private static boolean deleteCanBe(char[] cs, int k) {
            int n = cs.length, tar = (n - 1) / 2;
            int i = 0, j = n - 1;
            int cnt = 0;
            while (cnt < tar) {
                if (i == k) {
                    i++;
                } else if (j == k) {
                    j--;
                } else {
                    if (i >= j) {
                        return false;
                    }
                    if (cs[i] != cs[j]) {
                        return false;
                    }
                    cnt++;
                    i++;
                    j--;
                }
            }
            return true;
        }
    }

    @Test
    public void test() {
        System.out.println(Main1.deleteCanBe(new char[]{1, 2, 3,1, 1, 2, 1}, 2));
    }

    static class Main2 {

        private static int MIN = Integer.MAX_VALUE;
        private static int ei, ej, n;
        private static char[][] board;
        private static int[][] nexts = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
        private static Set<String> set = new HashSet<>();
        private static int[][] f;
        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            n = Integer.parseInt(sc.nextLine());
            int si = sc.nextInt(), sj = sc.nextInt();
            ei = sc.nextInt();
            ej = sc.nextInt();
            sc.nextLine();
            board = new char[n][];
            f = new int[n][n];

            for (int i = 0; i < n; i++) {
                board[i] = sc.nextLine().toCharArray();
                Arrays.fill(f[i], Integer.MAX_VALUE);
            }
            sc.close();

            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    System.out.print(board[i][j] + "\t");
                }
                System.out.println();
            }
            dfs(si, sj, 0, new ArrayList<>());
            for (int i = 0; i < n; i++) {
                System.out.println(i + "\t" + Arrays.toString(f[i]));
            }
            System.out.println(MIN);
        }

        private static void dfs(int i, int j, int steps, List<String> path) {
            if (i == ei && j == ej) {
                MIN = Math.min(steps, MIN);
                // System.out.println(path);
                if (steps == 9) {
                    StringBuffer sb = new StringBuffer();
                    for (int k = 0; k < path.size(); k++) {
                        String cur = path.get(k);
                        String[] ss = cur.split("_");
                        int ii = Integer.parseInt(ss[0]), jj = Integer.parseInt(ss[1]);
                        sb.append(board[ii][jj]).append("==>");
                    }
                    sb.append(board[ei][ej]);
                    System.out.println(sb.toString());
                }
                return;
            }
            String idx = i + "_" + j;
            if (i < 0 || i >= n || j < 0 || j >= n || 
                board[i][j] == '@' || board[i][j] == '#'
                || set.contains(idx)
                || f[i][j] <= steps) {
                //回溯
                return;
            }
            set.add(idx);
            f[i][j] = steps;
            path.add(idx);
            for (int k = 0; k < 4; k++) {
                dfs(i + nexts[k][0], j + nexts[k][1], steps + 1, path);
            }
            path.remove(path.size() - 1);
            set.remove(idx);
        }
    }

    public static void main(String[] args) {
        System.out.println(compileSeq("5,0,4,4,5,-1"));
    }

    public static String compileSeq (String input) {
        Map<Integer, List<Integer>> map = new HashMap<>();
        String[] ss = input.split(",");
        int n = ss.length;
        //int[] nums = new int[n];
        int cur;
        Queue<Integer> queue = new PriorityQueue<>();
        for (int i = 0; i < n; i++) {
            cur = Integer.parseInt(ss[i]);
            if (cur == -1) {
                queue.offer(i);
            } else {
                if (!map.containsKey(cur)) {
                    map.put(cur, new ArrayList<>());
                }
                map.get(cur).add(i);
            }
        }
        
        StringBuilder sb = new StringBuilder();
        
        while (!queue.isEmpty()) {
            cur = queue.poll();
            sb.append(cur).append(",");
            if (map.containsKey(cur)) {
                for (int next: map.get(cur)) {
                    queue.offer(next);
                }
            }
        }
        
        return sb.substring(0, sb.length() - 1);
    }
}
